/**
 * 功能描述
 */

define(function (require, exports, module) {
	var Grid = require("grid");
	var transferNotes = require("../store/transferNotes");
	var store =require("store");
    var instance = {
        initComponent: function (params,widget) {
        	var grid = new Grid({
        		parentNode:".J-grid",
        		url:"api/certificatestransfer/query",
        		params:function(){
        			var subnav = widget.get("subnav");
        			return {
        					"operateDate":subnav.getValue("operateDate").start,
        					"operateDateEnd":subnav.getValue("operateDate").end,
        					orderString:"",//签约时间降序排列
        					fetchProperties:"*,travelContract.*,travelContract.member.personalInfo.*,travelContract.productRule.product.*,travelContract.productType.*",//stransfer.fetchProperties余额
        			}
        		},
        		model:{
        			
        			columns:[{
        				name:"travelContract.memberCertificates",
        				label:"会员证号"
        			},{
        				name:"travelContract.contactNo",
        				label:"合同号"
        			},{
        				name:"travelContract.signUpDate",
        				label:"签约日期",
        				format:"date"
        			},{
        				name:"receiver.personalInfo.name",
        				label:"当前持证人"
        			},{
        				name:"travelContract.productRule.product.name",
        				label:"产品"
        			},{
        				name:"travelContract.productType.name",
        				label:"产品类型"
        			},{
        				name:"travelContract.number",
        				label:"份数"
        			},{
        				name:"travelContract.balance",
        				label:"余额",
        				format:function(val){
        					return Number(val).toFixed(2);
        				}
        			},{
        				name:"show",
        				label:"操作",
        				format:"button",
        				formatparams:[{
        					id:"edit",
        					key:"button",
        					text:"转让记录",
        						handler:function(index,data,rowEle){
//        							alert("合同號："+data.contactNo)
//        							alert("pkCertificatesTransfer:"+data.pkCertificatesTransfer)
        							widget.hide([".J-grid"]).show([".J-grid-show"]);
        							widget.get("subnav").show(["return"]).hide(["search", "operateDate"]);
        							var subnav = widget.get("subnav");
        							widget.get("showGrid").refresh({
        								
        								pkCertificatesTransfer:data.pkCertificatesTransfer,
        								contactNo:data.contactNo,
        								"operateDate":subnav.getValue("operateDate").start,
        	        					"operateDateEnd":subnav.getValue("operateDate").end,
        	        					fetchProperties:transferNotes.fetchProperties,
        							})
        						}
        				}]
        			}]
        		}
        	})
        	widget.set("grid", grid);
        }
    };
    module.exports = instance;
});
